package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import com.fr.report.script.core.FunctionHelper;

public class LN extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 1)
      return Primitive.ERROR_NAME;
    Object localObject = null;
    for (int i = 0; i < paramArrayOfObject.length; ++i)
    {
      localObject = paramArrayOfObject[i];
      if (localObject instanceof Number)
        return FunctionHelper.parsePrimitiveDouble(Math.log(((Number)localObject).doubleValue()));
    }
    return new Integer(0);
  }

  public Function.Type getType()
  {
    return Function.MATH;
  }

  public String getCN()
  {
    return "LN(number):返回一个数的自然对数。自然对数以常数项 e（2.71828182845904）为底。\nnumber:是用于计算其自然对数的正实数。\n示例:\nLN(86) 等于 4.45437\nLN(2.7182818) 等于 1\nLN(EXP(3)) 等于 3\nEXP(LN(4)) 等于 4\n";
  }

  public String getEN()
  {
    return "LN(number): Returns the natural logarithm of a number. Natural logarithms are based on the constant e (2.71828182845904).\nNumber is the positive real number for which you want the natural logarithm.\n\nExample:\n   LN(86) = 4.45437\n   LN(2.7182818) = 1\n   LN(EXP(3)) = 3\n   EXP(LN(4)) = 4\n";
  }
}